package com.example.livedatautilsdemo.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInstaller;
import android.util.Log;

/**
 * @author: njb
 * @date: 2023/8/9 9:45
 * @desc:
 */
public class UnInstallResultReceiver extends BroadcastReceiver {
    private static final String TAG = "uninstall";

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        Log.e("unInstall", "已收到卸载反馈广播");
        //安装广播
        if (intent != null) {
            final int status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS,
                    PackageInstaller.STATUS_FAILURE);
            if (status == PackageInstaller.STATUS_SUCCESS) {
                Log.d(TAG, "APP UnInstall Success!");
                // InstallAPP.getInstance().sendInstallSucces();
            } else {
                String msg = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE);
                Log.e(TAG, "UnInstall FAILURE status_massage" + msg);
                //InstallAPP.getInstance().sendFailure(msg);
            }
        }
    }
}
